const app = getApp()
const WXAPI = require("../../../../../api/newApi")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    changeIndex: 99,
    info:{},
    exchangeCount:'',//兑换蜂蜜分数量
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      statusHeight: app.gettop.height,
      status: app.gettop.status,
      navHeight: app.gettop.navHeight,
      mobbleBottom: app.mobile.mobbleBottom,
    })
    this.getInfo()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  handleChose(){
    wx.navigateBack({
      delta: 0,
    })
  },
  getInfo(){ //获取信息
    wx.showLoading({
      title: '加载中',
    })
    var data = {}
    WXAPI.getIntegralExchange(data, (res) => {
      if(res.code == 200){
        wx.hideLoading()
        this.setData({
          info: res.result,
          list: res.result.appPlatformCustomerIntegralExchangeInfoDTOList
        })
      }
    })
  },
  choice(e){
    let index = e.currentTarget.dataset.index
    this.data.exchangeCount = e.currentTarget.dataset.num
    this.setData({
      changeIndex: index
    })
  },
  setExchange(){ //integralExchange立即兑换
    wx.showLoading({
      title: '兑换中',
    })
    var data = {
      exchangeCount: this.data.exchangeCount
    }
    WXAPI.integralExchange(data, (res) => {
      if(res.code == 200){
        wx.hideLoading()
        wx.navigateTo({
          url: '../exchangeScuess/exchangeScuess?num=' + this.data.exchangeCount,
        })
      }
    })
  },
  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})